{% extends 'base.html' %}
<html lang="pt-br"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   {% block menu %}
          <div class="nav-collapse collapse">
            <p class="navbar-text pull-right">
              
      
              
            </p>
          
            <ul class="nav">
              <li><a href="/" id="id_link_home"> Home</a></li>
              <li class="active" id="id_link_about"> <a href="/projetos" >Projetos</a></li>
            <li><a href="/equipamentos" id="id_link_about">Equipamentos</a></li>
            </ul>
          
          </div><!--/.nav-collapse -->
          
          
        
          	{% endblock %}
{% block corpo %}

 
  <form action="/" method="post" class="form-inline">
        
            <input name="searchp" placeholder="pesquisar" maxlength="200" id="search" type="text" class="search-query"/>
            
        </form>

<form action="/projetos" method="post">
<div class="input-append" align="right">

            {{ formprojeto }}
            
            <button class="btn btn-small btn-default"><i class="icon-ok"></i></button>

</div>
</form>
 

{% if projetos %}
    
<table id="list_projetos_table" class="table table-hover">
        <thead>
            <tr>
            	<th class="span5" style="text-align: left;"> Projeto </th>
                <th class="span5" style="text-align: left;"> Custo em Equipamentos </th>
                <th class="span3"  style="text-align: left;" > Custo Mensal  </th>
                <th class="span2" style="text-align: left;" > Custo Anual </th>
                
            </tr>
        </thead>
        
        
        <tbody>
      {% for p in projetos %}
            <tr>
                <td class="span6">
                
                
                   <input id="projeto_{{ p.id }}" name="projeto_{{ p.id}}" type="text" value="" placeholder="Item" class="input-large" style="display: none;">
                    <a onclick="itemButton({{ p.id }});">
                        <a href="/verprojeto?id={{p.id}}">
                        <label id="label_projeto_{{ p.id }}">
                		 {{p.nome}}         
                        </label>
                        </a>
                    </a>
                
                   
                    
                   
                </td>
                
                <td class="span2" style="text-align: left">
                  R$ {{p.custoimplantacao|floatformat:2}}
                </td>
                <td class="span2" style="text-align: left">
                  R$ {{p.getcustomensalprojeto|floatformat:2}}
                </td>
                
                <td class="span2" style="text-align: left">
                   R$ {{p.getcustoanualprojeto|floatformat:2}}
                </td>
           	<td class="span2" style="text-align: center;">
                    <div id="edit_buttons_{{ p.id}}">
           
                        <button class="btn" onclick="removeButton({{ p.id}});"><i class="icon-trash"></i></button>
                    </div>
                </td>     
                
                
            </tr>
           {% endfor %} 
            
           
    
        </tbody>
                <th class="span2" style="text-align: left;" > 
        <form action="/allcsv" method="post">


            
            <input type="submit" value="csv" class="btn-small btn-primary" />


</form>
</th>
      
                
    </table>










{% else %}

Nao existem projetos


{% endif %}


   
                   
                
                
<script src="/templates/bootstrap/js/jquery.min.js" type="text/javascript"></script>
    <script src="/templates/bootstrap/bootstrap-modal.js"></script>
    <script src="/templates/bootstrap/bootstrap-dropdown.js"></script>
    <script src="/templates/bootstrap/bootstrap-transition.js"></script>
    <script src="/templates/bootstrap/bootstrap-alert.js"></script>
    <script src="/templates/bootstrap/bootstrap-scrollspy.js"></script>
    <script src="/templates/bootstrap/bootstrap-tab.js"></script>
    <script src="/templates/bootstrap/bootstrap-tooltip.js"></script>
    <script src="/templates/bootstrap/bootstrap-popover.js"></script>
    <script src="/templates/bootstrap/bootstrap-button.js"></script>
    <script src="/templates/bootstrap/bootstrap-collapse.js"></script>
    <script src="/templates/bootstrap/bootstrap-carousel.js"></script>
    <script src="/templates/bootstrap/bootstrap-typeahead.js"></script>

    <script src="/templates/bootstrap/shoplist_admin.js"></script>

    
   
<script type="text/javascript">


 $(function () {
    var minlength = 0;

    $("#search").keyup(function () {
    
        value = $(this).val();

        if (value.length >= minlength ) {
            $.ajax({
                type: "GET",
                url: "/projetos",
                
                data: {
                    'searchp' : value
                },
                
                success: function(data){
                    
                
                   	$("#list_projetos_table").empty();
                   	$("#list_projetos_table").append(data);
                   	
                    
                   
                }
                
                
            });
            
        }
    });
});






function removeButton(projeto_id)
    {
        if (confirm('Deseja realmente deletar o projeto "'+$("#label_projeto_"+projeto_id).text().trim()+'"?')) {
            $.ajax(
                {
                    type: "GET",
                    url: "/removeprojeto",
                    data: "id="+projeto_id,
                    success: function(data){
                        $("#edit_buttons_"+projeto_id).parent().parent().remove();
                        var row_count = $("#list_projetos_table > tbody > tr").length;
                        if (row_count == 0)
                            $("#list_projetos_table").remove();
                    }
                });
        }
    }

    $(document).keyup(function(e)
    {
        if (e.keyCode == 27) {
            $('input[name^="item_"]').hide();
            $('label[id^="label_item_"]').show();
            $('input[name^="quantidade_"]').hide();
            $('label[id^="label_quantidade_"]').show();
            $('div[id^="div_valor_"]').hide();
            $('label[id^="label_valor_"]').show();
            $('div[id^="edit_buttons_"]').show();
            $('div[id^="update_buttons_"]').hide();
        } // ESC pressed
        
        
    });  


</script>

    


{% endblock %}